﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:viewModel="clr-namespace:RPGOnlineWPF.ViewModel">
	<DataTemplate x:Key="ChatUsersDataTemplate" DataType="{x:Type viewModel:ChatViewModel}">
		<TabControl ItemsSource="{Binding Path=Groups}">
			<TabControl.ItemTemplate>
				<DataTemplate DataType="{x:Type viewModel:ChatGroupViewModel}">
					<TextBlock Text="{Binding Path=Name}"></TextBlock>
				</DataTemplate>
			</TabControl.ItemTemplate>
			<TabControl.ContentTemplate>
				<DataTemplate DataType="{x:Type viewModel:ChatGroupViewModel}">
					<ScrollViewer VerticalScrollBarVisibility="Auto">
						<ItemsControl ItemsSource="{Binding Path=Users}"></ItemsControl>
					</ScrollViewer>
				</DataTemplate>
			</TabControl.ContentTemplate>
		</TabControl>
	</DataTemplate>

	<DataTemplate x:Key="ChatConversationsDataTemplate" DataType="{x:Type viewModel:ChatViewModel}">
		<TabControl ItemsSource="{Binding Path=Conversations}">
			<TabControl.ItemTemplate>
				<DataTemplate DataType="{x:Type viewModel:ChatConversationViewModel}">
					<TextBlock Text="{Binding Path=Name}"></TextBlock>
				</DataTemplate>
			</TabControl.ItemTemplate>
			<TabControl.ContentTemplate>
				<DataTemplate DataType="{x:Type viewModel:ChatConversationViewModel}">
					<DockPanel>
						<DockPanel DockPanel.Dock="Bottom">
							<DockPanel DockPanel.Dock="Bottom">
								<Button Command="{Binding SendMessage}" Content="Send" DockPanel.Dock="Right"></Button>
								<TextBox Text="{Binding MessageToSend, UpdateSourceTrigger=PropertyChanged}">
									<TextBox.InputBindings>
										<KeyBinding Command="{Binding SendMessage}" Key="Enter"/>
									</TextBox.InputBindings>
								</TextBox>
							</DockPanel>
							<StackPanel Orientation="Horizontal">
								<Button Command="{Binding RollD4}" Content="d4"></Button>
								<Button Command="{Binding RollD6}" Content="d6"></Button>
								<Button Command="{Binding RollD8}" Content="d8"></Button>
								<Button Command="{Binding RollD10}" Content="d10"></Button>
								<Button Command="{Binding RollD12}" Content="d12"></Button>
								<Button Command="{Binding RollD20}" Content="d20"></Button>
								<Button Command="{Binding RollD100}" Content="d%"></Button>
							</StackPanel>
						</DockPanel>
						<ItemsControl Margin="0,5,0,5" ItemsSource="{Binding Path=Messages}" HorizontalContentAlignment="Stretch">
							<ItemsControl.Template>
								<ControlTemplate TargetType="{x:Type ItemsControl}">
									<ScrollViewer HorizontalAlignment="Stretch" CanContentScroll="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
										<ItemsPresenter HorizontalAlignment="Stretch"></ItemsPresenter>
									</ScrollViewer>
								</ControlTemplate>
							</ItemsControl.Template>
							<ItemsControl.ItemsPanel>
								<ItemsPanelTemplate>
									<WrapPanel Orientation="Vertical" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" ScrollViewer.IsDeferredScrollingEnabled="True"></WrapPanel>
								</ItemsPanelTemplate>
							</ItemsControl.ItemsPanel>
						</ItemsControl>
					</DockPanel>
				</DataTemplate>
			</TabControl.ContentTemplate>
		</TabControl>
	</DataTemplate>

	<DataTemplate DataType="{x:Type viewModel:ChatUserViewModel}">
		<StackPanel Orientation="Horizontal" Margin="0,0,0,5" HorizontalAlignment="Stretch">
			<Border CornerRadius="20" BorderThickness="4" BorderBrush="{Binding Color}" Width="40" Height="40" Margin="0,0,5,0">
				<Border.Background>
					<ImageBrush ImageSource="..\Resources\Koala.jpg" Opacity="0.8"></ImageBrush>
				</Border.Background>
			</Border>
			<StackPanel Orientation="Vertical" VerticalAlignment="Center">
				<TextBlock Text="{Binding Path=Name}"></TextBlock>
				<ProgressBar Width="150" Height="5" Maximum="{Binding TotalHP}" Value="{Binding HP, Mode=OneWay}" Foreground="Red" BorderBrush="#FF9A9A9A" Background="White" BorderThickness="0"></ProgressBar>
			</StackPanel>
		</StackPanel>
	</DataTemplate>

	<DataTemplate DataType="{x:Type viewModel:ChatMessageViewModel}">
		<Grid Margin="0,0,0,5" Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=WrapPanel}}">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"></ColumnDefinition>
				<ColumnDefinition Width="*"></ColumnDefinition>
			</Grid.ColumnDefinitions>
			<Path Grid.Column="0" StrokeThickness="0" Data="M 10,20 L 0,10 10,0" Fill="{Binding Color}" VerticalAlignment="Center" Margin="0,0,0,0" />
			<Border Grid.Column="1" MinHeight="20" Background="{Binding Color}" HorizontalAlignment="Left">
				<TextBlock Margin="5,0,5,0" Text="{Binding Message}" Foreground="{Binding TextColor}" VerticalAlignment="Center" TextWrapping="Wrap"></TextBlock>
			</Border>
		</Grid>
	</DataTemplate>

	<DataTemplate DataType="{x:Type viewModel:ChatLocalMessageViewModel}">
		<Grid Margin="0,0,0,5" Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=WrapPanel}}">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="*"></ColumnDefinition>
				<ColumnDefinition Width="Auto"></ColumnDefinition>
			</Grid.ColumnDefinitions>
			<Path Grid.Column="1" StrokeThickness="0" Data="M 0,20 L 10,10 0,0" Fill="{Binding Color}" VerticalAlignment="Center" Margin="0,0,0,0" />
			<Border Grid.Column="0" MinHeight="20" Background="{Binding Color}" HorizontalAlignment="Right">
				<TextBlock HorizontalAlignment="Right" Margin="5,0,5,0" Text="{Binding Message}" Foreground="{Binding TextColor}" VerticalAlignment="Center" TextWrapping="Wrap"></TextBlock>
			</Border>
		</Grid>
	</DataTemplate>

	<DataTemplate DataType="{x:Type viewModel:ChatSystemMessageViewModel}">
		<Grid Margin="0,0,0,5" Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=WrapPanel}}">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"></ColumnDefinition>
				<ColumnDefinition Width="*"></ColumnDefinition>
			</Grid.ColumnDefinitions>
			<Border Grid.Column="1" MinHeight="20" Background="DimGray" HorizontalAlignment="Left">
				<TextBlock Margin="5,0,5,0" Text="{Binding Message}" Foreground="White" VerticalAlignment="Center" TextWrapping="Wrap"></TextBlock>
			</Border>
		</Grid>
	</DataTemplate>

	<DataTemplate DataType="{x:Type viewModel:ChatDiceRollMessageViewModel}">
		<Grid Margin="0,0,0,5" Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=WrapPanel}}">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"></ColumnDefinition>
				<ColumnDefinition Width="*"></ColumnDefinition>
			</Grid.ColumnDefinitions>
			<Border Grid.Column="1" MinHeight="20" BorderBrush="DimGray" BorderThickness="2" CornerRadius="10" HorizontalAlignment="Left" Background="White">
				<TextBlock Margin="5,0,5,0" Text="{Binding Message}" Foreground="Black" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="16"></TextBlock>
			</Border>
		</Grid>
	</DataTemplate>
</ResourceDictionary>